package com.hunt.service.impl;

import com.github.pagehelper.PageHelper;
import com.hunt.dao.ActivityLogMapper;
import com.hunt.model.dto.PageInfo;
import com.hunt.model.entity.ActivityLog;
import com.hunt.model.entity.feedback;
import com.hunt.service.ActivityLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 新增操作日志记录
 * @author nine
 * @date 2024/5/16/016
 * @Description
 */
@Service
@Transactional
public class ActivityLogServiceImpl implements ActivityLogService {
    @Autowired
    private ActivityLogMapper activityLogMapper;
    @Override
    public int insertLog(String operator, String operationType, String operationInformation, String operationTime) {
        ActivityLog activityLog = new ActivityLog();
        activityLog.setOperator(operator);
        activityLog.setOperationType(operationType);
        activityLog.setOperationInformation(operationInformation);
        activityLog.setOperationTime(operationTime);
        return activityLogMapper.insert(activityLog);
    }

    @Override
    public PageInfo getactivitylogs(Integer page, Integer rows, String operator, String operationType) {
        int counts =activityLogMapper.selectCounts(operator,operationType);
        PageHelper.startPage(page, rows);
        List<ActivityLog> activityLogs =activityLogMapper.getactivityLogList(operator,operationType);
        PageInfo pageInfo = new PageInfo(counts,activityLogs);
        return pageInfo;
    }
}
